/*
 * Copyright (C) 2008,2009,2010,2011  Paulo Cesar Pereira de Andrade.
 *
 * This is free software; you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 *
 * This software is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU General Public License for more details.
 *
 * Authors:
 *	Paulo Cesar Pereira de Andrade
 */

#ifndef _etypes_h
#define _etypes_h

#include <unistd.h>
#include <stdlib.h>
#include <stdint.h>

#ifndef __WORDSIZE
#  define __WORDSIZE		WORDSIZE
#endif
#ifndef __BYTE_ORDER
#  define __BYTE_ORDER		BYTE_ORDER
#endif
#ifndef __LITTLE_ENDIAN
#  define __LITTLE_ENDIAN	LITTLE_ENDIAN
#endif
#ifndef __BIG_ENDIAN
#  define __BIG_ENDIAN		BIG_ENDIAN
#endif

/* Native types */
typedef signed char		eint8_t;
typedef unsigned char		euint8_t;
typedef signed short		eint16_t;
typedef unsigned short		euint16_t;
typedef signed int		eint32_t;
typedef unsigned int		euint32_t;
#if __WORDSIZE == 32
#  define SGN_MASK		0x7fffffff
typedef signed long long	eint64_t;
typedef unsigned long long	euint64_t;
#  define t_word		t_int32
#  define t_uword		t_uint32
#  define eword_t		eint32_t
#  define euword_t		euint32_t
#else
#  define SGN_MASK		0x7fffffffffffffff
typedef signed long		eint64_t;
typedef unsigned long		euint64_t;
#  define t_word		t_int64
#  define t_uword		t_uint64
#  define eword_t		eint64_t
#  define euword_t		euint64_t
#endif

typedef eint32_t		ebool_t;

#define eint_t			eint64_t
#define euint_t			euint64_t
#define efloat_t		efloat64_t

typedef float			efloat32_t;
typedef double			efloat64_t;
typedef void*			eobject_t;

typedef union {
    struct {
#if __BYTE_ORDER == __LITTLE_ENDIAN
	eint32_t		l;
	eint32_t		h;
#else
	eint32_t		h;
	eint32_t		l;
#endif
    } s;
    efloat32_t			f;
    eint_t			L;
    efloat_t			F;
    eobject_t			P;
} edata_t;

/* Multiple precision numeric types */
typedef __mpz_struct*		empz_t;
typedef __mpq_struct*		empq_t;
typedef __mpfr_struct*		empr_t;
typedef __mpf_struct*		empf_t;

/* Complex number types */
typedef complex double		ecdd_t;
typedef __cqq_struct*		ecqq_t;
typedef __mpc_struct*		empc_t;

/* Window system and user interface types */
typedef struct ebitmap		ebitmap_t;
typedef struct epixmap		epixmap_t;
typedef struct ewindow		ewindow_t;
typedef struct eevent		eevent_t;
typedef struct econtext		econtext_t;
typedef struct etimer		etimer_t;
typedef struct erect		erect_t;
typedef struct epoint		epoint_t;

/* Virtual machine hash table */
typedef struct ehashtable	ehashtable_t;
typedef struct ehashentry	ehashentry_t;

/* Implementation types */
typedef struct econs		econs_t;
typedef struct evector		evector_t;
typedef struct epointer		epointer_t;
typedef struct estream		estream_t;
typedef struct ehash		ehash_t;
typedef struct eentry		eentry_t;
typedef struct esymbol		esymbol_t;
typedef struct erecord		erecord_t,
				ebasic_t, estruct_t, eclass_t, eunion_t;
typedef struct efunction	efunction_t;
typedef struct eblock		eblock_t;
typedef struct etag		etag_t;
typedef struct elambda		elambda_t;
typedef struct ecase		ecase_t;
typedef struct evswitch		evswitch_t;
typedef struct ehswitch		ehswitch_t;
typedef struct ertti		ertti_t;
typedef struct efield		efield_t;
typedef struct emethod		emethod_t;
typedef struct ethread		ethread_t;
typedef struct empcache		empcache_t;
typedef struct emacro		emacro_t;

/* Special and/or stack only types */
typedef struct evalue		evalue_t;
typedef struct elocalref	elocalref_t;

typedef enum etype		etype_t;
typedef enum etoken		etoken_t;
typedef enum eopcode		ecode_t;
typedef enum eexcept		eexcept_t;

/* Intermediate representation/Abstract Syntax Tree */
typedef struct elabel		elabel_t;

typedef struct ecode_label	ecode_label_t;
typedef struct ecode_simple	ecode_simple_t;
typedef struct ecode_immediate	ecode_immediate_t;
typedef struct ecode_stack	ecode_stack_t;
typedef struct ecode_symbol	ecode_symbol_t;
typedef struct ecode_hash	ecode_hash_t;
typedef struct ecode_vector	ecode_vector_t;
typedef struct ecode_record	ecode_record_t;
typedef struct ecode_class	ecode_class_t;
typedef struct ecode_enter	ecode_enter_t;
typedef struct ecode_apply	ecode_apply_t;
typedef struct ecode_return	ecode_return_t;
typedef struct ecode_logic	ecode_logic_t;
typedef struct ecode_except	ecode_except_t;
typedef struct ecode_note	ecode_note_t;
typedef union east_node		east_node_t;

typedef struct east_list	east_list_t;

typedef struct essa_store_data	essa_store_data_t;
typedef struct essa_store	essa_store_t;
typedef struct essa_load_data	essa_load_data_t;
typedef struct essa_load	essa_load_t;

typedef struct edfa_rule	edfa_rule_t;
typedef struct edfa_range	edfa_range_t;

#endif /* _etypes_h */
